Part 3: Backend Infrastructure Architecture
| Item | Content |
|---|---|
| Document Name | Part 3: Backend Infrastructure Architecture |
| Product Name | DTA Wide Sleep Management Platform |
| Date | 2026-02-10 |
| Scope | Part 3 (Backend/Infrastructure) |
1. Infrastructure Overview
- Cloud Provider: Google Cloud Platform (GCP)
- Region:
europe-west3(Frankfurt, Germany) - GDPR/DiGA compliant - Deployment Model: Serverless (Cloud Run) + Managed Services
2. Network Architecture and Trust Boundaries
3. GCP Service Configuration
3.1 Compute
| Service | Purpose | Security Controls |
|---|---|---|
| Cloud Run (dta-wide-api) | NestJS API server | Service Account, VPC Connector, Private IP |
Auto-scaling:
- Minimum instances: 1 (prevent cold start)
- Maximum instances: 100
- Concurrency: 80 req/instance
3.2 Databases
| Service | Purpose | Backup | Encryption |
|---|---|---|---|
| Cloud SQL PostgreSQL | Users, sleep logs, questionnaires | Automatic daily backup (02:00), 30-day retention | AES-256-GCM (Cloud KMS) |
| Memorystore Redis | Sessions, cache, rate limit | Automatic backup | AES-256 (Google managed) |
| Firestore | Analysis logs, event stream | Automatic backup | AES-256 (Google managed) |
High Availability:
- Cloud SQL: Multi-zone HA (Failover < 60 seconds)
- Memorystore: Standard Tier (automatic replication)
- Firestore: Multi-region replication
3.3 Networking
| Component | Configuration | Security Controls |
|---|---|---|
| VPC Network | Private IP range: 10.0.0.0/16 | Firewall rules, Private Google Access |
| Serverless VPC Connector | Cloud Run → VPC connection | Cloud Run access only |
| Cloud NAT | Outbound traffic (external API) | Static IP, logging |
| Private Service Connect | Cloud SQL Private IP | VPC internal access only |
Firewall Rules:
- Inbound: HTTPS (443) only
- Outbound: Whitelist (PostgreSQL 5432, Redis 6379)
- SSH/RDP: Blocked (unnecessary for Cloud Run)
3.4 Security
| Service | Purpose | Configuration |
|---|---|---|
| Cloud KMS | Encryption key management | Root Key: HSM-backed, 90-day auto rotation |
| Secret Manager | API keys, DB passwords | Version Control, IAM access control |
| Cloud Armor | WAF, DDoS protection | OWASP Top 10 ruleset, IP whitelist [TODO: implementation verification needed] |
| VPC Service Controls | Data exfiltration prevention | Enforce europe-west3 region only |
4. Infrastructure Security Controls
4.1 IAM Role-Based Access Control
| Service Account | Role | Permission Scope |
|---|---|---|
dta-wide-api@... | Cloud Run API service | Cloud SQL Client, Secret Manager Accessor, Cloud Logging Writer |
db-admin@... | DB administrator | Cloud SQL Admin (read-only, approval required) |
ci-cd@... | CI/CD pipeline | Cloud Run Deployer, Container Registry Writer |
Least Privilege Principle:
- Each Service Account has only necessary minimum permissions
- Production DB write permission: API service only
- Developers: read-only
4.2 Secret Management
Secret Manager Usage:
secrets/
├── DATABASE_URL # PostgreSQL connection string
├── REDIS_URL # Redis connection string
├── JWT_SECRET # JWT signing key
├── OPENAI_API_KEY # OpenAI API key
└── MAILGUN_API_KEY # Email sending key
Access Control:
- Cloud Run Service Account access only
- Version management (keep latest 3 versions)
- Audit logging (secret access records)
5. Backup and Disaster Recovery (Backup & DR)
5.1 Backup Policy
| Data Type | Backup Frequency | Retention Period | Storage Location |
|---|---|---|---|
| PostgreSQL Main DB | Daily 02:00 (automatic) | 30 days | Cloud SQL automatic backup (europe-west3) |
| Firestore | Real-time replication | Unlimited (automatic) | Firestore Managed |
| Cloud Storage (logs) | Weekly archive | 1 year | Cloud Storage (Nearline) |
5.2 Disaster Recovery Plan
RPO (Recovery Point Objective): 1 hour
- Cloud SQL Point-in-Time Recovery supported
- Transaction logs retained 7 days
RTO (Recovery Time Objective): 4 hours
- Cloud SQL HA Failover: < 60 seconds
- Complete infrastructure rebuild: < 4 hours (Terraform automation)
DR Procedure:
- Cloud SQL Failover (automatic, < 60 seconds)
- Cloud Run auto-redeploy (new Zone)
- DNS update (Cloud DNS, TTL 60 seconds)
- Data integrity validation
- Service normalization confirmation
6. CI/CD Pipeline
6.1 Deployment Flow
6.2 Deployment Security Controls
| Stage | Security Check | Block Condition |
|---|---|---|
| Code Review | Security team review (Critical changes) | Unapproved |
| SAST | SonarCloud, Semgrep | Critical/High vulnerabilities |
| Container Scan | GCP Vulnerability Scanning | Critical CVE |
| Staging Deploy | E2E tests | Test failure |
| Production Deploy | Tech Lead approval | Unapproved |
7. Monitoring and Alerting
7.1 Key Metrics
| Metric | Threshold | Alert Recipient | Action |
|---|---|---|---|
| API Response Time (P95) | > 2 seconds | Operations | Performance investigation |
| Error Rate | > 5% | Operations + Development | Immediate investigation |
| DB Connection Pool | > 80% | DBA | Scale Up review |
| Redis Memory | > 90% | Operations | Cache cleanup or Scale Up |
| SSL Certificate Expiration | < 30 days | Security | Certificate renewal |
7.2 Alert Channels (TODO: Improvement)
- Critical: Slack
- High: Slack
- Medium: Slack
- Low: Slack
Evidence and References (Artifacts)
- Infrastructure Diagram (Section 2 of this document)
- GCP Project Structure Export -
artifacts/gcp-project-structure.json - Cloud Run Configuration -
cloudrun-deploy/service.yaml - Cloud SQL Configuration -
artifacts/cloudsql-config.json - IAM Role Definitions -
artifacts/iam-roles.json - VPC Firewall Rules -
artifacts/vpc-firewall-rules.json - Secret Manager Keys List -
artifacts/secret-manager-keys.json - CI/CD Pipeline -
.github/workflows/deployment-ci-europe.yml - Backup Policy Evidence - Cloud SQL backup configuration screenshot
- Monitoring Dashboard - Cloud Monitoring dashboard export
| Regulation | Requirement | Implementation | Evidence |
|---|---|---|---|
| BSI TR-03161 Part 3 | Secure infrastructure | VPC, Private IP, WAF | GCP configuration export |
| GDPR Article 32 | Appropriate technical measures | Encryption, access control, audit logging | This document |
| DiGA (BfArM) | German data residency | europe-west3 region enforcement | VPC Service Controls |